package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.ruoyi.system.domain.GuestbookAsk;
import com.ruoyi.system.service.IGuestbookAskService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.GuestbookReplyMapper;
import com.ruoyi.system.domain.GuestbookReply;
import com.ruoyi.system.service.IGuestbookReplyService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-07
 */
@Service
public class GuestbookReplyServiceImpl implements IGuestbookReplyService 
{
    @Autowired
    private GuestbookReplyMapper guestbookReplyMapper;

    @Autowired
    private IGuestbookAskService guestbookAskService;

    @Autowired
    private ISysUserService SysUserService;

    /**
     * 查询【请填写功能名称】
     * 
     * @param replyid 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public GuestbookReply selectGuestbookReplyByReplyid(String replyid)
    {
        return guestbookReplyMapper.selectGuestbookReplyByReplyid(replyid);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param guestbookReply 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<GuestbookReply> selectGuestbookReplyList(GuestbookReply guestbookReply)
    {
        return guestbookReplyMapper.selectGuestbookReplyList(guestbookReply);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param guestbookReply 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertGuestbookReply(GuestbookReply guestbookReply)
    {
        return guestbookReplyMapper.insertGuestbookReply(guestbookReply);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param guestbookReply 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateGuestbookReply(GuestbookReply guestbookReply)
    {
        return guestbookReplyMapper.updateGuestbookReply(guestbookReply);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param replyids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteGuestbookReplyByReplyids(String[] replyids)
    {
        return guestbookReplyMapper.deleteGuestbookReplyByReplyids(replyids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param replyid 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteGuestbookReplyByReplyid(String replyid)
    {
        return guestbookReplyMapper.deleteGuestbookReplyByReplyid(replyid);
    }

    @Override
    //查回复
    public List<Map<String, Object>> findByAskId(String ppAskId) {
        List<Map<String, Object>> mmReplyList = guestbookReplyMapper.findByAskId(ppAskId);
        List<Map<String, Object>> mmReturnList = new ArrayList<Map<String,Object>>();
        for (int i = 0; i < mmReplyList.size(); i++) {
            Map<String, Object> mmMap = mmReplyList.get(i);

            String mmAdminId = mmMap.get("huifurenid")== null ? "":mmMap.get("huifurenid").toString();

            String mmBumen = SysUserService.selectUserById(Long.parseLong(mmAdminId)).getNickName();

            mmMap.put("bumen", mmBumen);
            mmReturnList.add(mmMap);
        }

        return mmReturnList;
    }

}
